package com.akaovi.chatroom.client;

import com.akaovi.chatroom.process.OwnThread;
import com.akaovi.chatroom.scene.InfoBoard;
import com.akaovi.chatroom.scene.LoginScene;
import javafx.application.Application;
import javafx.application.HostServices;
import javafx.scene.image.Image;
import javafx.stage.Stage;

public class Client extends Application {
    static Stage stage = null;
    public static OwnThread ot;
    static String title = "Chat Room";

    @Override
    public void start(Stage stage) {
        // 暴露舞台
        Client.stage = stage;
        LoginScene.changeToLoginScene();
        stage.setResizable(false);
        stage.getIcons().add(new Image("title-icon.png"));
        stage.show();

        stage.setOnCloseRequest(e -> {
            if (ot != null && ot.isOnline) {
                ot.close();
            }
        });
        InfoBoard.icon1.setOnMouseClicked(e -> {
            HostServices host = this.getHostServices();
            host.showDocument("https://gitee.com/akaovi");
        });
        InfoBoard.icon2.setOnMouseClicked(e -> {
            HostServices host = this.getHostServices();
            host.showDocument("https://github.com/akaovi");
        });
        InfoBoard.icon3.setOnMouseClicked(e -> {
            HostServices host = this.getHostServices();
            host.showDocument("https://blog.akaovi.icu/");
        });
    }

    public static void main(String[] args) {
        launch();
    }

    public static Stage getStage() {
        return stage;
    }

}